<template>
  <div id="app">
    <van-tag type="primary" size="large" style="float: right;" @click="logout" v-if="isTabShow">退出</van-tag>
    <van-tabbar route v-model="active" v-if="isTabShow">
      <van-tabbar-item replace icon="home-o" to="/home">主页</van-tabbar-item>
      <van-tabbar-item replace icon="balance-list-o" to="/discripe">记账</van-tabbar-item>
      <van-tabbar-item replace icon="search" to="/search">搜索</van-tabbar-item>
      <!--<van-tabbar-item icon="setting-o">标签</van-tabbar-item>-->
    </van-tabbar>
    <router-view/>
  </div>
</template>

<script>
import {removeToken} from "@/api/getToken";

export default {
  name: 'App',
  data() {
    return {
      active: 0,
      isTabShow: false,
    }
  },
  watch:{
    "$route": function (to) {
        let tabArr = ['/home','/search','/discripe'];
        this.isTabShow = tabArr.includes(to.path);
    }
  },
  methods:{
    logout(){
      removeToken('token');
      this.$router.push('/login')
    }
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 0.133rem;
}
</style>
